package Controllers;

import java.io.IOException;

import Models.Device;
import Views.MonitorInfoWinController;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.*;

import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.AnchorPane;

import javafx.stage.Stage;



import javafx.application.Application;
import javafx.stage.Stage;

public class MainApp extends Application
{
	private Stage primaryStage;
	private BorderPane rootLayout;
	
	@Override
	public void start(Stage primaryStage) 
	{
		this.primaryStage = primaryStage;
		this.primaryStage.setTitle("ARES-EPPS1 Industrial Signal Monitor System");
		
		initRootLayout();
		monitorInfoWindow();
	}
	
	/*
	 * Initializes the root layout. 
	 */
	public void initRootLayout()
	{
		try
		{//Load root layout from fxml file.
			FXMLLoader loader = new FXMLLoader();
			loader.setLocation(MainApp.class.getResource("../Views/RootLayout.fxml"));
			rootLayout = (BorderPane)loader.load();
			
			//Show the scene containing the root layout.
			Scene scene = new Scene(rootLayout);
			primaryStage.setScene(scene);
			primaryStage.show();
		}catch(IOException e)
		{
			e.printStackTrace();
		}
	}
		
	/*
	 * Show the person overview inside the root layout.
	 * */
	public void monitorInfoWindow()
	{
		try
		{
			//Load person overview.
			FXMLLoader loader = new FXMLLoader();
			loader.setLocation(MainApp.class.getResource("../Views/MonitorInfoWindow.fxml"));
			BorderPane DeviceOverview = (BorderPane)loader.load();
				
			//Set person overview into the center of root layout.
			rootLayout.setCenter(DeviceOverview);
				
			//give the controller access to the main app.
			MonitorInfoWinController controller = loader.getController();
			//controller.setMainApp(this);
		}catch(IOException e)
		{
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) 
	{
		launch(args);
	}
}
